<template>
  <div class="recommend">
    <div class="top">
      <p>推荐歌单</p>
      <button>更多
         <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-gengduo"></use>
        </svg>
      </button>
    </div>

    <div class="recmusic">
      <van-swipe :loop="false" :width="150" :show-indicators="false">
        <van-swipe-item v-for="every in recommendMusic" :key="every.id" @click="jump(every.id)">
          <div class="pic">
            <img
              :src="every.picUrl"
              alt=""
              :style="{ width: '120px', height: '120px' }"
            />
            <p class="play">
              <span >
                <svg class="icon" aria-hidden="true">
                  <use xlink:href="#icon-yinle"></use>
                </svg>
              </span>
              <span>{{ getPlayCount(every.playCount) }}</span>
            </p>

            <p class="describe"> {{every.name}}</p>
          </div>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script>
import * as api from "@/api/getmusic";
import {mapMutations} from 'vuex'
export default {
  data() {
    return {
      recommendMusic: "",
      needData:''
    };
  },
  mounted() {
    api.recSongList().then((res) => {
      
      this.recommendMusic = res.data.result;
   
    });
  },

  methods:{
      ...mapMutations(['CHANGE_INDEX']),
      getPlayCount(count){
          return (count/10000).toFixed(1) + '万'
      },

      jump(id){
          this.$router.push({
              name:'songListItems',
              query:{
                  id
              }
          })
          this.$store.commit('CHANGE_INDEX')
      }
  }
};
</script>

<style scoped >
.recommend {
  padding: 0 10px;
  margin-top: 20px;
  width: 100%;
  box-sizing: border-box;
}
.top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.top button {
  border: 1px solid rgb(234, 231, 231);
  border-radius: 30px;
  font-size: 20px;
  background: pink;
}
.top p {
  font-weight: 600;
}
.van-swipe {
  height: 180px;
}
.van-swipe__track {
  height: 150px;
}
.pic{
    position: relative;
}
.play{
    position: absolute ;
    top: 10px;
    left: 40px;
}
.play span:nth-of-type(2){
    font-size:16px;
}

.describe{
    font-size: 13px;
    word-wrap:break-word;
    width: 130px;
    
}

</style>